import { BrowserWindow } from 'electron';
import { IPCCommnd } from '../const';
import { ProgressInfo } from '../biz/ipc/protocol/progress';

class ProgressUtil {
  private static instance: ProgressUtil;

  private window?: BrowserWindow;

  public static getInstance() {
    if (!this.instance) {
      this.instance = new ProgressUtil();
    }
    return this.instance;
  }

  public setWindow(window: BrowserWindow) {
    this.window = window;
  }

  public sendProgress(progressInfo: ProgressInfo) {
    if (this.window) {
      this.window.webContents.send(IPCCommnd.MainSendProgress, progressInfo);
    }
  }
}
export default ProgressUtil;
